﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataAccessLayer
{
    public class EmployeeRepository
    {
        StationeryInventoryEntities1 ent;

        public EmployeeRepository()
        {
            ent = new StationeryInventoryEntities1();
        }

        #region Select Method
        public Employee GetEmployeeByUserId(int userId)
        {
            Employee employee = new Employee();

            var emp = ent.Employees.FirstOrDefault(x => x.UserID == userId);

            if (emp != null)
            {
                employee = emp;
            }
            return employee;
        }

        public List<Employee> GetEmployeeByRoleName(string roleName)
        {
            List<Employee> list = new List<Employee>();

            var emp = ent.Employees.Where(x => x.User.Role.RoleName == roleName);

            if (emp != null)
            {
                list = emp.ToList();
            }
            return list;
        }

        #endregion
    }
}
